package com.muyu.user.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.user.service.SysUserCouponService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.muyu.user.domain.req.SysUserCouponQueryReq;
import com.muyu.user.domain.model.SysUserCouponQueryModel;
import com.muyu.user.domain.model.SysUserCouponPageQueryModel;
import com.muyu.user.domain.resp.SysUserCouponPageResp;
import com.muyu.common.core.web.page.DataPageResp;
import com.muyu.common.core.web.page.PageQueryModel;

/**
 * 用户优惠券记录Controller
 *
 * @author liuguoqiang
 * @date 2025-09-18
 */
@RestController
@RequestMapping("/coupon")
@Tag(name = "用户优惠券记录", description = "用户优惠券记录控制层")
public class SysUserCouponController extends BaseController {

    /**
    * 用户优惠券记录业务层
    */
    @Autowired
    private SysUserCouponService sysUserCouponService;

    /**
     * 查询用户优惠券记录列表
     */
    @Operation(summary = "获取用户优惠券记录列表", description = "获取用户优惠券记录列表")
    @RequiresPermissions("user:coupon:list")
    @GetMapping("/list")
    public Result<DataPageResp<SysUserCouponPageResp>> list(SysUserCouponQueryReq sysUserCouponQueryReq) {
        PageQueryModel<SysUserCouponPageQueryModel> pageQueryModel = sysUserCouponService.pageQuery(SysUserCouponQueryModel.reqBuild(sysUserCouponQueryReq));
        return Result.success(DataPageResp.of(pageQueryModel).cover(SysUserCouponPageResp::infoBuild));
    }

}
